package com.nl.lib_core.base

import android.os.Bundle
import com.nl.lib_core.mvp.BaseModel
import com.nl.lib_core.mvp.BasePresenter

/** 作者: wangfei 创建时间: 2021/9/1 包名: com.nl.lib_core.base 类名: BaseMvpFragment */
abstract class BaseMvpFragment<M : BaseModel, V, P : BasePresenter<M, V>> : BaseFragment() {

  private var mPresenter: P? = null

  override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    mPresenter = initPresenter()
    mPresenter?.attach(this as V)
    mPresenter?.injectLifecycleOwner(mActivity)
  }

  override fun onDestroy() {
    mPresenter?.detach()
    super.onDestroy()
  }

  abstract fun initPresenter(): P
}
